import React from 'react';
import { observer } from 'mobx-react-lite';
import { Button, Space } from 'antd';
import { useStore } from '@/core/store';
import language from "@/locales/zh_cn";

interface Props {
  loading: boolean;
  submit: (payload: any) => void;
}

const DispatchAction: React.FC<Props> = observer(({ loading, submit }) => {
  const appStore = useStore();
  // const language = useLanguage();

  const handleClose = () => {
    appStore.routerBar.onClose(undefined, '/work-task/manager');
  };

  return (
    <Space className="dispatch-action mt-10" style={{ width: '100%', justifyContent: 'flex-end' }}>
      <Button onClick={handleClose}>
        {language.cancel}
      </Button>
      <Button 
        type="primary" 
        loading={loading} 
        onClick={submit}
      >
        {language.submit}
      </Button>
    </Space>
  );
});

export default DispatchAction;